**************************************************************************************************
*** This do file creates the replication results for 
*** Conditional Spatial Policy Dependence: Theory and Model Specification 					 	*/
*** Thomas Pluemper (University of Essex)														*/
*** Eric Neumayer (LSE)																			*/
*** 																							*/
*** Published in: Comparative Political Studies, 2012											*/
**************************************************************************************************
**************************************************************************************************
/* Note: 
You have to change "local DIR" to the directory you copy the original stata files contained 	*/
/* in the zip file and then run the do file. 													*/
**************************************************************************************************

version 11.0
drop _all
clear matrix
clear mata
set mem 800m
set mat 5000

capture net install outreg2, from(http://fmwww.bc.edu/RePEc/bocode/o)			/* checks whether outreg2 is installed 		*/

***********************************************************************************
local DIR = "C:\Research\Development finance\Barthel\"  /*change relative path to the directory where the files are located */
cd "`DIR'"
***********************************************************************************

use "Article for CPS (spatial).dta", clear

stset year, id(dyadid) failure(dtt) enter (indep_new) origin(time year==1925)

* model 1
stcox  L1_exp_market_sim_plus lnpop_prod lngdppc_prod L1_ln_trade2 prod_openness_trade bitdummy rta  ofc_oecd dipl_repr lndistance polconv_prod  oecd_oecd oecd_nonoecd  indep_years L1_dtt_max L1_cumm_rep L1_cumm_host, nohr vce(cluster dyadid)
outreg2 using table1.xls, stats(coef se) replace

* model 2
capture drop interact
gen interact=c.L1_exp_market_sim_plus#c.L1_dtt_max 

stcox  L1_exp_market_sim_plus interact lnpop_prod lngdppc_prod L1_ln_trade2 prod_openness_trade  bitdummy rta  ofc_oecd dipl_repr lndistance polconv_prod  oecd_oecd oecd_nonoecd  indep_years L1_dtt_max L1_cumm_rep L1_cumm_host if e(sample), nohr vce(cluster dyadid)
outreg2 using table1.xls, stats(coef se) append


* Take the vector of the entire interaction effect
capture drop interactvector
gen interactvector=_b[ L1_exp_market_sim_plus]* L1_exp_market_sim_plus+_b[ L1_dtt_max]* L1_dtt_max+_b[ interact]* interact

* model 3: Re-estimated with the vector
stcox   interactvector lnpop_prod lngdppc_prod L1_ln_trade2 prod_openness_trade  bitdummy rta  ofc_oecd dipl_repr lndistance polconv_prod  oecd_oecd oecd_nonoecd  indep_years L1_cumm_rep L1_cumm_host if e(sample), nohr vce(cluster dyadid)
outreg2 using table1.xls, stats(coef se) append

* model 4: Interact vector with dummy variable if one of countries has nationalist executive
stcox   interactvector c.interactvector#c. nationalist_dum_either  nationalist_dum_either  lnpop_prod lngdppc_prod L1_ln_trade2 prod_openness_trade  bitdummy rta  ofc_oecd dipl_repr lndistance polconv_prod  oecd_oecd oecd_nonoecd  indep_years L1_cumm_rep L1_cumm_host if e(sample), nohr vce(cluster dyadid)
outreg2 using table1.xls, stats(coef se) append
